<template>
  <div class="container">
    <div class="hyzx">
      <section class="zxsc2 af">
        <div class="left">

          <ul class="nr">
            <li v-for="(ct,ind) in title.info2" class="af" :key="ct.ind">
              <nuxt-link  :to="'/Details/'+ct.id" target="_blank" style="display: block;height: 100%;">
                <img :src="'https://exam.zhonghaiqihang.com/'+ct.image" width="248px" height="182px">
                <div class="ctrt">
                  <h5>{{ct.title}}</h5>
                  <p class="p1">{{ct.summary}}</p>
                  <div class="ctdb">
                    <span class="house">来源：中海启航集团</span>
                    <em>阅读量：{{ct.readnum}}</em>
                    <i>时间：{{ct.createtime}}</i>
                  </div>
                </div>
              </nuxt-link>
              <!--:href="'https://www.qiyebang.net.cn/xq/?name='+ct.id"-->
            </li>
          </ul>
          <div class="dbqh">
            <a href="javascript:;" @click="syz">首页</a><a href="javascript:;" @click="syy">上一页</a> <a href="javascript:;" v-for="(i,id) in sl4" @click="qh(i*6+1)" :class="i==sl3?'select':''">{{i+1}}</a>

            <a href="javascript:;" @click="xyy">下一页</a><a href="javascript:;" @click="xyz">尾页</a>
          </div>

        </div>

      </section>
    </div>
    <my-ft></my-ft>
  </div>
</template>
<script>
  import axios from 'axios';
  import $ from 'jquery';
  export default {
    name: 'HelloWorld',
    data () {
      return {
        num:0,
        selenv:false,
        title:null,
        dlzt:'',
        sl: 1,
        sl4:[0,1,2,3,4],
        dysl2:'',
        djshu:0,
        msg:undefined,
        sl3:0,
        ctnm:0,
        num1:'0',
        infoshuju:null,
        sl2:[1],
        xq:null,
        yqljData:null,
        fuwu:1
      }
    },
    async asyncData ({ params }) {
    let nh = await axios.get(`https://exam.zhonghaiqihang.com/PInterface/Header/headerData`);
    let nh3 = await axios.get(`https://exam.zhonghaiqihang.com/PInterface/Info/infoData`,{
      pramas:{
        num: '0'
      }
    });
    let nh4 = 1;
    let data  = {nav:nh.data,info:nh3.data,info2:nh3.data.info[0].info,sl:nh4};
    return { title: data}
  },
  mounted: function () {
    console.log(this.title)
    this.ctnm = this.title.info.info[0].countnum;
    console.log(this.title.info.info[0].countnum)
    for(let i=1;i<=this.title.info.info[0].countnum;i+=6){
      if(i>1){
        this.sl2.push(i);
      }
    }
    // this.dysl2 = this.sl2;

    // if(this.sl2.length>=10){
    //   this.sl2 = [1].concat(this.dysl2.slice(1,9));
    // }
    if(this.$route.query.name){


      this.num1 = 0;
      this.sl2 = [1];
      this.sl3 = 0;

      // this.title.info2 = this.title.info.info[this.$route.query.name - 1].info;
      // var _this = this;
      // _this.$axios.get('https://exam.zhonghaiqihang.com/' + '/PInterface/Info/infoData')
        // .then(function (response) {
        //   _this.title.info = response.data;
        //   _this.title.info2 = response.data.info[_this.$route.query.name - 1].info;
        //   _this.ctnm = _this.title.info.info[_this.$route.query.name - 1].countnum;
        //   if(Math.ceil(_this.ctnm/6)==1){
        //     _this.sl4=[0]
        //   }else if(Math.ceil(_this.ctnm/6)==2){
        //     _this.sl4=[0,1]
        //   }else if(Math.ceil(_this.ctnm/6)==3){
        //     _this.sl4=[0,1,2]
        //   }else if(Math.ceil(_this.ctnm/6)==4){
        //     _this.sl4=[0,1,2,3]
        //   }else if(Math.ceil(_this.ctnm/6)==5){
        //     _this.sl4=[0,1,2,3,4]
        //   }else if(Math.ceil(_this.ctnm/6)>5){
        //     _this.sl4=[0,1,2,3,4]
        //   }


        //   for (let i = 1; i <= _this.title.info.info[_this.$route.query.name - 1].countnum; i += 6) {
        //     if (i > 1) {
        //       _this.sl2.push(i);
        //     }
        //   }
        // });

    }



  }
  ,head () {
    return {
      title: '创业攻略_解读政策_企业百科-企业邦',
      meta: [
        { hid: 'description', name: 'description', content: '企业邦-24小时免费服务:400-855-1888,为企业提供加急注册公司,提供注册地址,变更,注销,商标注册,公司转让,代理记账,国家局核名,疑难核名,解除税务异常,解公司地址异常,年报异常,公司收购,资质代办,建筑施工资质,总承包资质,专业承包资质,劳务资质,代办执照,北京公司户车指标,购车指标,车号,食品经营许可证,广播电视节目许可,联网资质,直播资质,人力资源劳务派遣,旅行社资质,知识产权代理,税收筹划等专业的全方位企业服务' },
        { hid: 'keywords', name: 'keywords',content: '北京公司注册,北京注册公司,北京代理记账,北京工商变更,北京公司注销,北京公司转让,回收公司,注册公司,公司注册,工商注册,公司变更,代理记账,公司转让,公司注销,公司收购,资质代办,代办执照,汽车指标,食品经营许可证 '}
      ]
    }
  },
  methods:{

    qh:function(e){
      this.num1 = e-1;
      this.sl3 = (e-1)/6;
      // if((this.sl3+1)%5==0){
      //   this.djshu = this.sl3+1;
      // }

      var _this = this;
      _this.$axios.get('https://exam.zhonghaiqihang.com/'+'PInterface/Info/infoData',{
        params:{
          num:_this.num1
        }
      })
        .then(function(response){
          _this.title.info2 = response.data.info[_this.title.sl-1].info;

        });



    },
    syz:function(){
      var _this = this;
      this.num1 = 0;
      this.sl3 = 0;
      // if((this.sl3+1)%5==0){
      //   this.djshu = this.sl3+1;
      // }

      var _this = this;
      _this.$axios.get('https://exam.zhonghaiqihang.com/'+'PInterface/Info/infoData',{
        params:{
          num:_this.num1
        }
      })
        .then(function(response){

          _this.title.info2 = response.data.info[_this.title.sl-1].info;
           console.log(_this.title.info2)

        });
      if(Math.ceil(_this.ctnm/6)==1){
        _this.sl4=[0]
      }else if(Math.ceil(_this.ctnm/6)==2){
        _this.sl4=[0,1]
      }else if(Math.ceil(_this.ctnm/6)==3){
        _this.sl4=[0,1,2]
      }else if(Math.ceil(_this.ctnm/6)==4){
        _this.sl4=[0,1,2,3]
      }else if(Math.ceil(_this.ctnm/6)==5){
        _this.sl4=[0,1,2,3,4]
      }else if(Math.ceil(_this.ctnm/6)>5){
        _this.sl4=[0,1,2,3,4]
      }

    },
    xyz:function(){

      var _this = this;
      this.num1 = Math.ceil(_this.ctnm/6)*6-6;
      this.sl3 = Math.ceil(_this.ctnm/6)-1;
      // if((this.sl3+1)%5==0){
      //   this.djshu = this.sl3+1;
      // }

      var _this = this;
      _this.$axios.get('https://exam.zhonghaiqihang.com/'+'PInterface/Info/infoData',{
        params:{
          num:_this.num1
        }
      })
        .then(function(response){
          _this.title.info2 = response.data.info[_this.title.sl-1].info;
            console.log(_this.title.info2)
        });
      if(Math.ceil(_this.ctnm/6)==1){
        _this.sl4=[0]
      }else if(Math.ceil(_this.ctnm/6)==2){
        _this.sl4=[0,1]
      }else if(Math.ceil(_this.ctnm/6)==3){
        _this.sl4=[0,1,2]
      }else if(Math.ceil(_this.ctnm/6)==4){
        _this.sl4=[0,1,2,3]
      }else if(Math.ceil(_this.ctnm/6)==5){
        _this.sl4=[0,1,2,3,4]
      }else if(Math.ceil(_this.ctnm/6)>5){
        _this.sl4=[Math.ceil(_this.ctnm/6)-5,Math.ceil(_this.ctnm/6)-4,Math.ceil(_this.ctnm/6)-3,Math.ceil(_this.ctnm/6)-2,Math.ceil(_this.ctnm/6)-1]
      }

    },
    syy:function(){
      if(this.num1>=6){
        if(this.sl3>this.sl4[0]){
          var _this = this;
          _this.num1 = parseInt(_this.num1)-6;
          _this.$axios.get('https://exam.zhonghaiqihang.com/'+'PInterface/Info/infoData',{
            params:{
              num:_this.num1
            }
          })
            .then(function(response){
              _this.title.info = response.data;
              _this.title.info2 = response.data.info[_this.sl-1].info;
              _this.sl3 = _this.sl3-1;
              if((_this.sl3+1)%5==0){
                _this.djshu = _this.sl3+1;
              }
            });
        }else if(this.sl3!=0){
          var _this = this;
          for(let i=0;i<this.sl4.length;i++){
            this.sl4[i]=this.sl4[i]-1
          }
          _this.num1 = parseInt(_this.num1)-6;
          _this.$axios.get('https://exam.zhonghaiqihang.com/'+'PInterface/Info/infoData',{
            params:{
              num:_this.num1
            }
          })
            .then(function(response){
              _this.title.info = response.data;
              _this.title.info2 = response.data.info[_this.sl-1].info;

              _this.sl3 = _this.sl3-1;
              if((_this.sl3+1)%5==0){
                _this.djshu = _this.sl3+1;
              }
            });
        }

      }
    },
    xyy:function(){
        console.log(this.ctnm)
      if((this.num1+6)< this.ctnm){
        // alert(12)
        // if (this.sl3<this.sl4[4]){


        //   var _this = this;
        //   _this.num1 = parseInt(_this.num1)+6;
        //   _this.$axios.get('https://exam.zhonghaiqihang.com/'+'PInterface/Info/infoData',{
        //     params:{
        //       num:_this.num1
        //     }
        //   })
        //     .then(function(response){
        //       _this.title.info = response.data;
        //       _this.title.info2 = response.data.info[_this.sl-1].info;
        //       _this.sl3 = _this.sl3+1;
        //       if((_this.sl3+1)%5==0){
        //         _this.djshu = _this.sl3-1;
        //       }
        //     });
        // }else if(this.sl3<this.ctnm){
        //   var  _this = this;
        //   _this.num1 = parseInt(_this.num1)+6;
        //   _this.$axios.get('https://exam.zhonghaiqihang.com/'+'PInterface/Info/infoData',{
        //     params:{
        //       num:_this.num1
        //     }
        //   })
        //     .then(function(response){
        //       _this.title.info = response.data;
        //       _this.title.info2 = response.data.info[_this.sl-1].info;
        //       _this.sl3 = _this.sl3+1;
        //       if((_this.sl3+1)%5==0){
        //         _this.djshu = _this.sl3-1;
        //       }
        //     });
        //   var _this = this;
        //   for(let i=0;i<this.sl4.length;i++){
        //     this.sl4[i]=this.sl4[i]+1
        //   }

        // }


      }


    }
  }
  }
</script>

<style>

</style>
